<template>
    <el-menu
      :default-active="activeRoute"
      class="sidebar-menu"
      :collapse="!sidebarOpen"
      router
      background-color="#001529"
      text-color="#bfcbd9"
      active-text-color="#409EFF"
    >
      <div class="logo-container">
        <el-icon :size="28" color="#409EFF">
          <Money />
        </el-icon>
        <h1 v-show="sidebarOpen" class="logo-text">PaySaaS</h1>
      </div>
  
      <el-menu-item index="/">
        <el-icon><Monitor /></el-icon>
        <template #title>控制台</template>
      </el-menu-item>
  
      <el-menu-item index="/transactions">
        <el-icon><List /></el-icon>
        <template #title>交易记录</template>
      </el-menu-item>
  
      <el-menu-item index="/billing">
        <el-icon><Document /></el-icon>
        <template #title>账单管理</template>
      </el-menu-item>
  
      <el-sub-menu index="reports">
        <template #title>
          <el-icon><DataAnalysis /></el-icon>
          <span>报表分析</span>
        </template>
        <el-menu-item index="/reports/income">收入报表</el-menu-item>
        <el-menu-item index="/reports/customers">客户分析</el-menu-item>
        <el-menu-item index="/reports/transactions">交易分析</el-menu-item>
      </el-sub-menu>
  
      <el-menu-item index="/settings">
        <el-icon><Setting /></el-icon>
        <template #title>系统设置</template>
      </el-menu-item>
    </el-menu>
  </template>
  
  <script lang="ts" setup>
  import { computed } from 'vue'
  import { useRoute } from 'vue-router'
  import { useAppStore } from '../store'
  import {
    Money,
    Monitor,
    List,
    Document,
    DataAnalysis,
    Setting
  } from '@element-plus/icons-vue'
  
  const route = useRoute()
  const store = useAppStore()
  
  const activeRoute = computed(() => route.path)
  const sidebarOpen = computed(() => store.sidebarOpen)
  </script>
  
  <style lang="scss" scoped>
  .sidebar-menu {
    height: 100vh;
    border-right: none;
    transition: width 0.3s ease;
    
    &:not(.el-menu--collapse) {
      width: 240px;
    }
  
    .logo-container {
      display: flex;
      align-items: center;
      padding: 20px 16px;
      height: 60px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  
      .logo-text {
        margin-left: 12px;
        font-size: 18px;
        color: #fff;
        font-weight: bold;
      }
    }
  
    .el-menu-item,
    :deep(.el-sub-menu__title) {
      height: 50px;
      line-height: 50px;
      
      &:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
      }
    }
  }
  </style>